package com.ktjiaoyu.ktmall.servlet.api;/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */


import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * This sample demonstrates how to get started with basic requests to Aliyun OSS 
 * using the OSS SDK for Java.
 */
public class GetStartedSample {
    
    private static String endpoint = "http://oss-cn-guangzhou.aliyuncs.com";
    private static String accessKeyId ="LTAI5tBjanHTeEkYVPGgpGpk";// ""
    private static String accessKeySecret = "B07G6cZrDYafy1aV0m9d4IJOAsOVgv";//"";
    private static String bucketName = "ktmall2025913"; ///test-ssm-file
    private static String key = "img4.jpg";
    
    public static void main(String[] args) throws IOException {
        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

        // 上传文件流。
        InputStream inputStream = null;
        try {
            //本地文件路径  //注意换成自己电脑本地的真实文件路径
            inputStream = new FileInputStream("C:\\Users\\lenovo\\Desktop\\新建文件夹\\img4.jpg");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        //
        ossClient.putObject(bucketName,key, inputStream);

        // 关闭OSSClient。
        ossClient.shutdown();
    }

}
